﻿using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Test_WebDriver.Utilities
{
	/// <summary>
	///		<para>Summary: Manage your processes.</para>
	///		<para>Author: Heller (Hellersong@outlook.com)</para>
	///		<para>Creation: 7/12/2015 10:22:41 AM</para>
	/// </summary>
	public class ProcessUtility
	{
		#region Fields
		public const String EXE_NOTEPAD = "notepad.exe";
		public const String EXE_CMD = "cmd.exe";
		public const String EXE_EXCEL = "excel.exe";
		public const String EXE_BROWSER_IE = "iexplore.exe";
		public const String EXE_BROWSER_CHROME = "firefox.exe";
		public const String EXE_BROWSER_FIREFOX = "chrome.exe";
		public const String EXE_SELENIUM_IESERVER = "IEDriverServer.exe";
		public const String EXE_SELENIUM_CHROMESERVER = "chromedriver.exe";
		#endregion

		/// <summary>
		///		Notice: Really pay attention! This will destroy all threads without saving.
		/// </summary>
		public static void EndProcess(String exeName)
		{
			try
			{
				foreach (Process p in Process.GetProcesses())
				{
					if (exeName.Contains(p.ProcessName))
					{
						p.Kill();
					}

				}
			}
			catch (Exception)
			{
			}
			
		}
	}
}
